package com.test.transactional.controller;

import com.test.transactional.model.Dept;
import com.test.transactional.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DeptController {

    @Autowired
    private DeptService deptService;


    @GetMapping("list")
    public List<Dept> list() {
        return deptService.list();
    }

    @GetMapping("addDept")
    public void addDept() {
        // 同一个对象中 没有事务的方法调用有事务的方法， 有事务的方法不回滚
        // deptService.doAddDept();
        deptService.addDept();
    }
}
